From af73380a31d7597a8c348a815f651c02868bc3cb Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 5 Apr 2006 15:00:42 +0100 Subject: [PATCH] Rename update_dom_time() to update_vcpu_system_time(). Introduce new generic function update_domain_wallclock_time(). Signed-off-by: Keir Fraser --- xen/arch/ia64/xen/xentime.c | 8 +++++++- xen/arch/x86/domain.c | 2 +- xen/arch/x86/domain_build.c | 2 +- xen/arch/x86/time.c | 41 +++++++++++++++---------------------- xen/common/schedule.c | 6 +++--- xen/include/asm-x86/time.h | 3 --- xen/include/xen/time.h | 4 +++- 7 files changed, 31 insertions(+), 35 deletions(-) diff --git a/xen/arch/ia64/xen/xentime.c b/xen/arch/ia64/xen/xentime.c index af784f7f06..97a615440d 100644 --- a/xen/arch/ia64/xen/xentime.c +++ b/xen/arch/ia64/xen/xentime.c @@ -84,7 +84,13 @@ s_time_t get_s_time(void) return now; } -void update_dom_time(struct vcpu *v) +void update_vcpu_system_time(struct vcpu *v) +{ + /* N-op here, and let dom0 to manage system time directly */ + return; +} + +void update_domain_wallclock_time(struct domain *d) { /* N-op here, and let dom0 to manage system time directly */ return; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a4e52139bd..b52770ef80 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -363,7 +363,7 @@ int arch_set_info_guest( update_pagetables(v); if ( v->vcpu_id == 0 ) - init_domain_time(d); + update_domain_wallclock_time(d); /* Don't redo final setup */ set_bit(_VCPUF_initialised, &v->vcpu_flags); diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 1a80aeb36f..599753a613 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -773,7 +773,7 @@ int construct_dom0(struct domain *d, zap_low_mappings(idle_pg_table_l2); #endif - init_domain_time(d); + update_domain_wallclock_time(d); set_bit(_VCPUF_initialised, &v->vcpu_flags); diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 286df06a6f..ef4c7901bd 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -670,7 +670,7 @@ static inline void version_update_end(u32 *version) (*version)++; } -static inline void __update_dom_time(struct vcpu *v) +static inline void __update_vcpu_system_time(struct vcpu *v) { struct cpu_time *t; struct vcpu_time_info *u; @@ -688,11 +688,21 @@ static inline void __update_dom_time(struct vcpu *v) version_update_end(&u->version); } -void update_dom_time(struct vcpu *v) +void update_vcpu_system_time(struct vcpu *v) { if ( v->domain->shared_info->vcpu_info[v->vcpu_id].time.tsc_timestamp != cpu_time[smp_processor_id()].local_tsc_stamp ) - __update_dom_time(v); + __update_vcpu_system_time(v); +} + +void update_domain_wallclock_time(struct domain *d) +{ + spin_lock(&wc_lock); + version_update_begin(&d->shared_info->wc_version); + d->shared_info->wc_sec = wc_sec; + d->shared_info->wc_nsec = wc_nsec; + version_update_end(&d->shared_info->wc_version); + spin_unlock(&wc_lock); } /* Set clock to after 00:00:00 UTC, 1 January, 1970. */ @@ -701,40 +711,21 @@ void do_settime(unsigned long secs, unsigned long nsecs, u64 system_time_base) u64 x; u32 y, _wc_sec, _wc_nsec; struct domain *d; - shared_info_t *s; x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base; y = do_div(x, 1000000000); + spin_lock(&wc_lock); wc_sec = _wc_sec = (u32)x; wc_nsec = _wc_nsec = (u32)y; + spin_unlock(&wc_lock); read_lock(&domlist_lock); - spin_lock(&wc_lock); - for_each_domain ( d ) - { - s = d->shared_info; - version_update_begin(&s->wc_version); - s->wc_sec = _wc_sec; - s->wc_nsec = _wc_nsec; - version_update_end(&s->wc_version); - } - - spin_unlock(&wc_lock); + update_domain_wallclock_time(d); read_unlock(&domlist_lock); } -void init_domain_time(struct domain *d) -{ - spin_lock(&wc_lock); - version_update_begin(&d->shared_info->wc_version); - d->shared_info->wc_sec = wc_sec; - d->shared_info->wc_nsec = wc_nsec; - version_update_end(&d->shared_info->wc_version); - spin_unlock(&wc_lock); -} - static void local_time_calibration(void *unused) { unsigned int cpu = smp_processor_id(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 4ab5d7d879..0b1644ea5a 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -572,7 +572,7 @@ static void __enter_scheduler(void) /* Ensure that the domain has an up-to-date time base. */ if ( !is_idle_vcpu(next) ) { - update_dom_time(next); + update_vcpu_system_time(next); if ( next->sleep_tick != schedule_data[cpu].tick ) send_timer_event(next); } @@ -609,7 +609,7 @@ static void t_timer_fn(void *unused) if ( !is_idle_vcpu(v) ) { - update_dom_time(v); + update_vcpu_system_time(v); send_timer_event(v); } @@ -623,7 +623,7 @@ static void dom_timer_fn(void *data) { struct vcpu *v = data; - update_dom_time(v); + update_vcpu_system_time(v); send_timer_event(v); } diff --git a/xen/include/asm-x86/time.h b/xen/include/asm-x86/time.h index 38e4dffcf2..731ce9500e 100644 --- a/xen/include/asm-x86/time.h +++ b/xen/include/asm-x86/time.h @@ -7,9 +7,6 @@ extern void calibrate_tsc_bp(void); extern void calibrate_tsc_ap(void); -struct domain; -extern void init_domain_time(struct domain *d); - typedef u64 cycles_t; static inline cycles_t get_cycles(void) diff --git a/xen/include/xen/time.h b/xen/include/xen/time.h index 3a31af0112..931401388e 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -55,7 +55,9 @@ s_time_t get_s_time(void); #define MILLISECS(_ms) ((s_time_t)((_ms) * 1000000ULL)) #define MICROSECS(_us) ((s_time_t)((_us) * 1000ULL)) -extern void update_dom_time(struct vcpu *v); +extern void update_vcpu_system_time(struct vcpu *v); +extern void update_domain_wallclock_time(struct domain *d); + extern void do_settime( unsigned long secs, unsigned long nsecs, u64 system_time_base); -- 2.30.2